package cn.iocoder.yudao.module.dify.dal.mysql.fileprocessing;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.dify.dal.dataobject.fileprocessing.FileProcessingDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.dify.controller.admin.fileprocessing.vo.*;

/**
 * Dify文件处理跟踪 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface FileProcessingMapper extends BaseMapperX<FileProcessingDO> {

    default PageResult<FileProcessingDO> selectPage(FileProcessingPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FileProcessingDO>()
                .eqIfPresent(FileProcessingDO::getUserId, reqVO.getUserId())
                .eqIfPresent(FileProcessingDO::getOriginalFilepath, reqVO.getOriginalFilepath())
                .eqIfPresent(FileProcessingDO::getProcessedFilepath, reqVO.getProcessedFilepath())
                .eqIfPresent(FileProcessingDO::getProcessingStatus, reqVO.getProcessingStatus())
                .betweenIfPresent(FileProcessingDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(FileProcessingDO::getProcessingStartedAt, reqVO.getProcessingStartedAt())
                .eqIfPresent(FileProcessingDO::getProcessingCompletedAt, reqVO.getProcessingCompletedAt())
                .orderByDesc(FileProcessingDO::getId));
    }

    default List<FileProcessingDO> selectListByUserId(Long userId){
        return selectList( FileProcessingDO::getCreator,userId);
    }

    default List<FileProcessingDO> selectListByDifyFileId(List<String> fileIdList){

        return selectList(new LambdaQueryWrapperX<FileProcessingDO>().inIfPresent(FileProcessingDO::getDifyFileId,fileIdList));
    }
}